// 首先，有负权边表示只能用bellman-ford或者SPFA算法
// 这里要求有边数限制，所以只能用bellman-ford算法
// 时间复杂度：O(nm)
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

struct edge
{
    int a, b, c;
};

const int N = 10010;
edge rode[N];
int dist[N], backup[N];
int n, m, k;

int bellman_ford()
{
    memset(dist, 0x3f, sizeof dist);
    dist[1] = 0;
    for (int i = 0; i < k; ++i)
    {
        memcpy(backup, dist, sizeof dist);
        // 由于可能出现串联的现象，所以需要先拷贝一下
        for (int j = 0; j < m; ++j)
        {
            // cout << m << endl;
            int a = rode[j].a, b = rode[j].b, c = rode[j].c;
            // cout << a << ' ' << b << ' ' << c << endl;
            dist[b] = min(dist[b], backup[a] + c);
        }
    }
    return dist[n];
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> n >> m >> k;
    for (int i = 0; i < m; ++i)
    {
        int a, b, c;
        cin >> a >> b >> c;
        rode[i].a = a, rode[i].b = b, rode[i].c = c;
    }
    int t = bellman_ford();
    // cout << t << endl;
    // 由于负边的存在，不能直接判断等于0x3f3f3f3f
    if (t > 0x3f3f3f3f / 2)
        cout << "impossible\n";
    else
        cout << t << endl;
    return 0;
}
